package com.ruoyi.depot.mapper;

import java.math.BigDecimal;
import java.util.List;

import com.ruoyi.common.api.localInventory.dto.LocalInventoryDto;
import com.ruoyi.depot.domain.LocalInventory;
import com.ruoyi.depot.domain.dto.LocalInventoryUpdate;
import com.ruoyi.depot.domain.vo.InventoryProductVO;
import com.ruoyi.depot.domain.vo.LocalInventoryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.core.parameters.P;

/**
 * 库存Mapper接口
 * 
 * @author luxiaoyu
 * @date 2024-12-19
 */
@Mapper
public interface LocalInventoryMapper 
{
    /**
     * 查询库存
     * 
     * @param inventoryId 库存主键
     * @return 库存
     */
    public LocalInventory selectLocalInventoryByInventoryId(String inventoryId);

    /**
     * 查询库存列表
     * 
     * @param localInventory 库存
     * @return 库存集合
     */
    public List<LocalInventoryVO> selectLocalInventoryList(LocalInventory localInventory);

    /**
     * 新增库存
     * 
     * @param localInventory 库存
     * @return 结果
     */
    public int insertLocalInventory(LocalInventory localInventory);

    /**
     * 根据产品id修改库存
     * @param productId
     * @param warehouseId
     * @param version
     * @param inspectedQuantity
     * @return
     */
    public int updateLocalInventory(@Param("productId") Long productId,
                             @Param("warehouseId") Long warehouseId,
                             @Param("version") Integer version,
                             @Param("inspectedQuantity") BigDecimal inspectedQuantity);


    /**
     * 根据sku修改库存
     * @param sku
     * @param warehouseId
     * @param version
     * @param inspectedQuantity
     * @return
     */
    public int updateLocalInventoryBySku(@Param("sku") String sku,
                                    @Param("warehouseId") Integer warehouseId,
                                    @Param("version") Integer version,
                                    @Param("inspectedQuantity") BigDecimal inspectedQuantity);

    /**
     * 删除库存
     * 
     * @param inventoryId 库存主键
     * @return 结果
     */
    public int deleteLocalInventoryByInventoryId(Long inventoryId);

    /**
     * 批量删除库存
     * 
     * @param inventoryIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteLocalInventoryByInventoryIds(Long[] inventoryIds);

    /**
     * 根据产品id查询对应的库存信息
     * @param productId
     * @return
     */
    public LocalInventory selectProductSku(@Param("productId") Long productId,@Param("warehouseId") Long warehouseId);


    /**
     * 查询新增库存盘点中的产品信息
     * @param vo
     * @return
     */
    List<InventoryProductVO> selectProductListByWarehouseId(@Param("vo") InventoryProductVO vo);


    /**
     * 查询对应的所有库存信息
     * @param skus
     * @param warehouseIds
     * @return
     */
    List<LocalInventory> selectProductsBySkusAndWarehouses(@Param("skus") List<String> skus, @Param("warehouseIds") List<Long> warehouseIds);

    /**
     * 批量更新库存
     * @param inventoryUpdates
     * @return
     */
    int updateBatch(@Param("list") List<LocalInventoryUpdate> inventoryUpdates);
    /**
     * 修改预定量/锁定量
     */
    int updateReservedQuantity(LocalInventory localInventory);
    /**
     * 根据sku批量查询库存数据
     * @param collect
     * @param stockWarehouse
     * @return
     */
    List<LocalInventoryVO> selectSku(@Param("skus") List<String> collect,@Param("stockWarehouse") Integer stockWarehouse);

    /**
     * 根据sku和仓库查询库存信息
     * @param sku
     * @param stockWarehouse
     * @return
     */
    LocalInventory selectBySkuAndWarehouse(@Param("sku") String sku,@Param("stockWarehouse") Integer stockWarehouse);

    LocalInventoryDto selectLocalInventoryBySkuAndWarehouseId(@Param("sku") String sku,@Param("warehouseId") Long warehouseId);
}
